﻿using Abp.Dependency;
using NetCore.Dtos;
using NetCore.Entities.Organizations;
using NetCore.Organizations.Dtos;
using NetCore.Services;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

namespace NetCore.Organizations
{
    /// <summary>
    /// IOrganizationService 仅有的接口
    /// </summary>
    [Description("组织机构")]
    public interface IOrganizationAppService : IBaseNetCoreAppService<Organization>, ITransientDependency
    {
        /// <summary>
        /// 获取所有组织机构
        /// </summary>
        /// <returns></returns>
        Task<IList<OrganizationDto>> Grid();

        /// <summary>
        /// 获取所有叶子节点Id
        /// </summary>
        /// <returns>获取所有叶子节点Id</returns>
        Task<List<int>> GetLeafNodeIds();

        /// <summary>
        /// 获取所有父级节点Id
        /// </summary>
        /// <returns>获取所有父级节点Id</returns>
        Task<List<int?>> GetParentNodeIds();
        /// <summary>
        /// 根据父级机构集合 获取所有子级机构集合 GetChildrens
        /// </summary>
        /// <param name="parents">父级机构集合</param>
        /// <returns>子级机构集合</returns>
        Task<List<Organization>> GetChildrens(List<Organization> parents);
        /// <summary>
        /// 获取某组织机构下的子级机构
        /// </summary>
        /// <param name="input">ids:parentIds父级Ids集合</param>
        /// <returns>某组织机构下的子级机构</returns>
        Task<IEnumerable<OrganizationDto>> GetChildrenByItemIds(InputIdsDto input);
        /// <summary>
        /// 获取某组织机构的所有子级
        /// </summary>
        /// <param name="input">Id:parentId</param>
        /// <returns></returns>
        Task<IEnumerable<OrganizationDto>> GetChildrenByItemId(InputIdDto input);
        /// <summary>
        /// 获取某组织下所有子级机构
        /// </summary>
        /// <param name="input">Id:organizationId</param>
        /// <returns></returns>
        Task<List<OrganizationDto>> GetAllChildren(InputIdDto input);

        /// <summary>
        /// 获取某组织集合 下所有子级机构
        /// </summary>
        /// <param name="input">ids：parentIds某组织集合</param>
        /// <returns>子级机构集合</returns>
        Task<List<OrganizationDto>> GetAllChildrenByItemIds(InputIdsDto input);
        /// <summary>
        /// 根据父级找出所有同级节点
        /// </summary>
        /// <param name="input">id:parentId父级机构Id</param>
        /// <returns>其子级与所有同级机构</returns>
        Task<List<Organization>> GetBrothersByParentId(InputIdDto input);
        /// <summary>
        /// 根据当前节点父级Id 找出所有父级
        /// </summary>
        /// <param name="input">id:parentId当前节点父级Id</param>
        /// <returns>所有父级机构集合</returns>
        Task<List<Organization>> GetAllParentsByParentId(InputIdDto input);
        /// <summary>
        /// 根级节点treeView数据源
        /// </summary>
        /// <param name="input">ids:selectedIds</param>
        /// <returns>TreeDtos</returns>
        Task<List<TreeDto>> GetRootItemTree(InputIdsDto input);

        /// <summary>
        /// 所有节点treeView数据源
        /// </summary>
        /// <param name="input">ids:selectedIds</param>
        /// <returns>TreeDto</returns>
        Task<List<TreeDto>> GetRootTrees(InputIdsDto input);

        /// <summary>
        /// 更新子级层级 UpdateChildrenLevels
        /// </summary>
        /// <returns>SelectBoxs</returns>
        void UpdateChildrenLevels(IQueryable<Organization> parents);
        /// <summary>
        /// 获取所有父级SelectBoxsGetParentSelectList
        /// </summary>
        /// <returns>SelectBoxs</returns>
        Task<IQueryable<SelectBox>> GetParentSelectList();
    }
}
